package client.gui;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

class PieChartPanel extends JPanel{

    private final Color colorUsedSpace = new Color(0, 0, 255);
    private final Color colorFreeSpace = new Color(255, 0, 255);
    private final Color colorUsedRarc  = new Color(157,206, 78);
    private int angleSpaceUsedRarc;
    private int angleSpaceWithoutRarc;


    public void setValues(long totalSpace, long rArcUsed, long usedSpace){
        angleSpaceUsedRarc = (int) ((360 * rArcUsed) / totalSpace);
        angleSpaceWithoutRarc = (int) (( 360 * usedSpace) / totalSpace);
    }

    @Override
    public void paintComponent(Graphics g){      
        
        g.setColor(colorUsedRarc);
        g.fillArc(5,5, getWidth() - 6, getHeight()- 6, 0,
                angleSpaceUsedRarc);
        
        g.setColor(colorUsedSpace);
        g.fillArc(5,5, getWidth() - 6, getHeight()- 6,
                angleSpaceUsedRarc, angleSpaceWithoutRarc);

        g.setColor(colorFreeSpace);
        g.fillArc(5,5, getWidth()- 6, getHeight()- 6,
                angleSpaceUsedRarc+angleSpaceWithoutRarc,
                360 - (angleSpaceUsedRarc+angleSpaceWithoutRarc));
       
    }


}

    